-
Notifications
You must be signed in to change notification settings - Fork 16
no issue - introduce anonymizator Context #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5ff2c62 to
4b229a3
Compare
53c9e20 to
be29e73
Compare
be29e73 to
eba1c0f
Compare
|
Following our discussions on matrix, I did remove the bc layer, rationale being:
Impact for most if not all users should null. |
| #[\Deprecated(message: "Will be removed in 3.0, use \$this->context->salt instead.", since: "2.1.0")] | ||
| protected function getSalt(): string | ||
| { | ||
| return $this->options->get('salt') ?? Anonymizator::generateRandomSalt(); | ||
| return $this->context->salt; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can directly get rid of this
| private AnonymizationConfig $anonymizationConfig, | ||
| private ?string $salt = null, | ||
| ?Context $defaultContext = null, | ||
| ) { | ||
| $this->logger = new NullLogger(); | ||
| $this->output = new NullOutput(); | ||
| $this->defaultContext = $defaultContext ?? new Context(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I in favor of keeping things the most simple as we can. Here, can we use the both options for the $defaultContext property ?
- If we always give a
$defaultContext, I think we should not accept it to be null. - If we never give a
$defaultContext, then we should remove it from params and always prepopulate it in constructor.
I think we should not introduce behavior we don't need because it is more code to maintain, and it makes things more complicated to understand.
| } | ||
|
|
||
| $plan = []; | ||
| $context = clone $this->defaultContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given taht $context is readonly in AbstractAnonymizer, why do you need to clone it here ?
In many occasions, we need to share context for a single anonyzation run between anonymizers:
All this data must go directly to anonymizers, but using the
Optionsinstance is wrong:The less impactful solution I found is the following:
Contextclass, which will carry all this information.AbstractAnonymizerin order to accept this new parameter.But we have a problem here, it's BC break, and a huge one, it will cause a refactor of all our tests, and possibly create problems with existing custom anonymizers in the wild (I guess there's not much, but you never know). This can be mitigated by the fact that people should extend our abstract implementations and probably won't override the constructor, but you never know, it's public API now.
So, temporary ulgy solution:
ContextextendOptions(even if it makes no sense) and pass it toAbstractAnonymizer::__construct(): no signature change needed.AbstractAnonymizer::__construct()to check validity of input, and create a dummyContextinstance whenOptionsare passed instead.Options $optionsandContext $context(which will not extendOptionsanymore).